<?
include('/www/resellers_advanced/login/wallet_db.html');
//translate############################################################################
$user_tbl=translate('user_tbl');
$domain_tbl=translate('domain_tbl');
$no_clients=translate('no_clients');
$buton_back=translate('buton_back');
$buton_next=translate('buton_next');
$database_error=translate('database_error');
$domain_taken=translate('domain_taken');
$registrant_info=translate('registrant_info');
$domain_tbl=translate('domain_tbl');
$expiration_d=translate('expiration_d');
$firstname_tbl=translate('firstname');
$lastname_tbl=translate('lastname');
$e_mail=translate('e_mail');
$address_tbl=translate('address_tbl');
$city_tbl=translate('city_tbl');
$state_tbl=translate('state_tbl');
$zip_tbl=translate('zip_tbl');
$country_tbl=translate('country_tbl');
$phone_tbl=translate('phone_tbl');
$payment_method=translate('payment_method');
//translate############################################################################
if (!isset($_POST[form_submit])) {
	$params[sid] = $sid;
	$params[action] = 'register_domain';
	$action_url = "$baseURL/$webDIR/?".encode_params($params);
	
	echo "<table width='90%' class='bTable' cellpadding=0 cellspacing=0>
	<form action='$action_url' method='POST'>
	<tr>
		<th align='left' width=50%>$user_tbl :</th>
		<th align='left' width=50%>$domain_tbl :</th>
	</tr>";
	//-----------------------------------------------------
	$sql['type'] = "SELECT";
	$sql['params'] = "client_id, username, firstname, lastname";
	$sql['table'] = "clients";
	$sql['where'] = "reseller_id='$id' AND blocked=0";
	$sql['options'] = "ORDER BY username";
	$sql['return'] = "struct";
	//------------------------------------------------------
	if (!$result=sql_exec($sql,$dbh81,'assoc')) {
		exit($no_clients);
	}
	foreach ($result as $value) {
		$clients[$value[client_id]]=$value[username];
	}
	echo "<tr>
	<td align='left' width='50%'><select name='username'>
		<option value=0>----------</option>\n";
	foreach ($clients as $val) {
		echo "<option value='$val'>$val</option>\n";
	}
	echo "</select></td>";
	echo "<td align='left' width='50%' nowrap>";
	
	if (!empty($sld) && !empty($sld)) {
		echo "<b>$sld."."$tld</b></td>";
		echo "<input type='hidden' name='sld' value='$sld'>
		<input type='hidden' name='tld' value='$tld'>";
	} else {
		echo "<input type=text name=sld>&nbsp;
			<select name=tld>
				<option value='com'>.com</option>
				<option value='net'>.net</option>
				<option value='org'>.org</option>
				<option value='biz'>.biz</option>
				<option value='us'>.us</option>
				<option value='info'>.info</option>
			</select>";
	}
	echo "</td>
	</tr>
	<tr>
		<td colspan='2' align='center'>
			<input type='button' value='$buton_back' class='buttonNormal' id='Back' onClick='window.history.back();'>&nbsp;
		        <input type='submit' class='buttonNormal' id='Forward' value='$buton_next'>
		        <input type='hidden' name='form_submit' value='yes'>
					
	</tr>
	</form>
	</table>";
} else {

//-----------------------------------------------------------------------------
$sql['type'] = "query";
$sql['params'] = "SELECT check_domain('".$_POST[sld]."') as result";
$sql['table'] = "";
$sql['where'] = "";
$sql['options'] = "";
$sql['return'] = "hash";
//------------------------------------------------------
if (!$result=sql_exec($sql,$dbh81,'assoc')) {
	exit($database_error);
}
$result=$result['result'];
$result=trim($result);
$result=explode("\n",$result);
foreach ($result as $value) {
	$value=explode("|",$value);
	$dom[$value[0]]=$value[1];
}
$domain2reg=$_POST[sld].".".$_POST[tld];
if ($dom[$domain2reg]!='available') exit($domain_taken);
//-----------------------------------------------------
$sql['type'] = "SELECT";
$sql['params'] = "firstname, lastname, email, address1, address2, city, state, zip, country, phone";
$sql['table'] = "clients";
$sql['where'] = "reseller_id='$id' AND username='$_POST[username]'";
$sql['options'] = "";
$sql['return'] = "struct";
//------------------------------------------------------
if (!$result=sql_exec($sql,$dbh81,'assoc')) {
	exit($database_error);
}
$firstname=$result[0][firstname];
$lastname=$result[0][lastname];
$email=$result[0][email];
$address1=$result[0][address1];
$address2=$result[0][address2];
$city=$result[0][city];
$state=$result[0][state];
$zip=$result[0][zip];
$country=$result[0][country];
$phone=$result[0][phone];

$action_url='https://supremeserver1.com/resellers/u/order/order_domain.php';
unset($params);
$params[sid] = $sid;
$params[action] = 'register_domain';
$return_url = "$baseURL/$webDIR/?".encode_params($params);
		
echo "<table width='90%' class='bTable' cellpadding=0 cellspacing=0>
<form action='$action_url' method='POST'>
<tr>
<td align='right'>$domain_tbl :</td>
        <td  align='left'><b>$_POST[sld]."."$_POST[tld]</b>
		<input type='hidden' name='sld' value='$_POST[sld]'>
                <input type='hidden' name='tld' value='$_POST[tld]'></td>
</tr>
<tr>
        <td align='left' colspan='2'>$registrant_info :</td>
</tr>
  <tr>
    <td align='right'>$firstname_tbl :</td>
    <td><input type='text' name='firstname' value='$firstname'></td>
  </tr>
  <tr>
    <td align='right'>$lastname_tbl :</td>
    <td><input type='text' name='lastname' value='$lastname'></td>
  </tr>
  <tr>
    <td align='right'>$e_mail:</td>
    <td><input type='text' name='email' value='$email'></td>
  </tr>
  <tr>
    <td align='right'>$address_tbl :</td>
    <td><input type='text' name='address1' value='$address1'></td>
  </tr>
  <tr>
    <td align='right'>&nbsp;</td>
    <td><input type='text' name='address2' value='$address2'></td>
  </tr>
  <tr>
    <td align='right'>$city_tbl :</td>
    <td><input type='text' name='city' value='$city'></td>
  </tr>
  <tr>
    <td align='right'>$state_tbl :</td>
    <td><input type='text' name='state' value='$state'></td>
  </tr>
  <tr>
    <td align='right'>$zip_tbl: </td>
    <td><input type='text' name='zip' value='$zip'></td>
  </tr>
  <tr>
    <td align='right'>$country_tbl :</td>
	<td>
        <select name='country'>";
                echo get_countries($country);
        echo "</select>
    </td>
  </tr>
  <tr>
    <td align='right'>$phone_tbl :</td>
    <td><input type='text' name='phone' value='$phone'></td>
  </tr>
  <tr>
        <td align='right'>$payment_method :</td><td>";
                                if(!$_POST[payment_method]) $_POST[payment_method]='cc';
                            echo "<input type=radio name=payment_method value='cc'"; if($_POST[payment_method]=='cc') echo 'checked'; echo ">Credit Card
                            <input type=radio name=payment_method value='pp'"; if($_POST[payment_method]=='pp') echo 'checkd'; echo " >PayPal
                            <input type=radio name=payment_method value='wallet'"; if($_POST[payment_method]=='wallet') echo 'checkd'; echo " >Wallet
      </td>
  </tr>
<tr>
        <td colspan='4' align='center'>
                <input type='hidden' name='username' value='$_POST[username]'>
                <input type='hidden' name='return_url' value='$return_url'>
                <input type='button' value='$buton_back' class='buttonNormal' id='Back' onClick='window.history.back();'>&nbsp;
                <input type='submit' class='buttonNormal' id='Forward'value='$buton_next'>
        </td>
</tr>
</form>
</table>";
}
